<?php
declare (strict_types = 1);

namespace app\admin\validate;

use think\Validate;

class MarketSocialMediaAccount extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id' => 'require|integer',
        'channel_id' => 'require|integer',
        'account' => 'require|max:512',
        'pass' => 'require|max:512',
        'appkey' => 'require|max:512',
        'secret' => 'require|max:512',
        'prompt' => 'require|max:512',
        'language' => 'require|integer',
        'country' => 'require|integer',
        'status' => 'in:0,1',
        'is_del' => 'in:0,1',
        'creator' => 'nullable|integer',
        'updater' => 'nullable|integer',
        'create_time' => 'datetime',
        'update_time' => 'nullable|datetime',
        'ids' => 'require|array',
        'account_group_id' => 'require|integer',
        'windows_id' => 'string'
    ];

    // 错误信息
    protected $message = [
        'channel_id.require' => '渠道Id必须填写',
        'channel_id.integer' => '渠道Id必须是整数',
        'account.require' => '账号必须填写',
        'account.max' => '账号长度不能超过512个字符',
        'pass.require' => '密码必须填写',
        'pass.max' => '密码长度不能超过512个字符',
        'appkey.require' => 'appkey必须填写',
        'appkey.max' => 'appkey长度不能超过512个字符',
        'secret.require' => 'secret必须填写',
        'secret.max' => 'secret长度不能超过512个字符',
        'prompt.require' => '提示词必须填写',
        'prompt.max' => '提示词长度不能超过512个字符',
        'language.require' => '语言必须填写',
        'language.integer' => '语言必须是整数',
        'country.require' => '国家必须填写',
        'country.integer' => '国家必须是整数',
        'status.in' => '状态必须是0或1',
        'is_del.in' => '是否删除必须是0或1',
        'creator.integer' => '创建人必须是整数',
        'updater.integer' => '更新人必须是整数',
        'create_time.datetime' => '创建时间格式不正确',
        'update_time.datetime' => '更新时间格式不正确',
    ];

    // 场景定义
    protected $scene = [
        'save' => ['channel_id', 'language','country','account','pass','status','account_group_id','windows_id'],
//        'edit' => ['id', 'channel_id', 'account', 'pass', 'appkey', 'secret', 'prompt', 'language', 'country', 'status', 'is_del', 'updater'],
        'delete' => ['ids'],
        'search' => ['status','windows_id'],
        'update' => ['id','windows_id'],
        'show' => ['id','windows_id'],
        'status' => ['ids', 'status'],
    ];
}
